import json
import time

import api_chengtou
import api_qmai
from zz import zz_log, zz_code, zz_return, zz_dingtalk, zz_str
import api_fund
from bs4 import BeautifulSoup

# log = zz_log.of(logging.DEBUG)
log = zz_log.of()


# api_url = 'https://fund.eastmoney.com/008929.html'
# api_url = 'https://fundgz.1234567.com.cn/js/008929.js?rt=1746241232544'
# h = api_fund.Handle("008929")
# html = h.get_html(api_url)
# print(html)
# fund_data_str = html.replace("jsonpgz(", "")
# fund_data_str = fund_data_str.replace(");", "")
# print(fund_data_str)
# fund_json = json.loads(fund_data_str)
# print(fund_json)

# soup = BeautifulSoup(html, 'html.parser')
# fond_name = soup.find('div', attrs={'class': 'fundDetail-tit'})
# soup = BeautifulSoup(html, 'html.parser')
# print(f"{fond_name.div.text})")


# a = {
#     "a": "1",
#     "b": "2",
#     "c": "3"
# }
# for k, v in a.items():
#     print(k, v)
# print(a['a'])
# print(zz_code.arr_find(a, "a"))
#
# zz_code.config_set('test', 'aaa')
#
# print(','.join(['a', 'b']))
# #
# zz_dingtalk.send_markdown("### test \n\n ## 123123 <b style='color:red;'>test</b>", 'title')
# log.info(zz_code.date_tostring('%Y-%m'))
# log.info(zz_code.date_timestamp_ms())
# api_chengtou.run()

# api_jm.run()

# api_mz.run()
# log.info(zz_str.url_encode('{"user_id":"t5hi4621700","com_id":"10018"}'))
# log.info(zz_str.url_decode('%7B%22user_id%22%3A%22t5hi4621700%22%2C%22com_id%22%3A%2210018%22%7D'))

# api_chengtou.run()

# api_qmai.run()
# api_0818tuan.run()

# print(logging.DEBUG)

# string = "Python的字符串对象提供了许多内置方法，可以方便地进行字符串的模糊查询。下面是一些常用的方法示例"
# pattern = ["123|abc", '方法']
# result = re.findall(pattern, string)
# print(result)
# match = re.search(pattern, string)
# print(match)
# print(match.group())
# print(zz_str.contains(string, ''))

# b = zz_code.date_now()
# time.sleep(2)
# e = zz_code.date_now()
# time_duration = e - b
# print(round(time_duration.seconds / 60, 1))

# a = './game/img/灵魂序章/play_alert01.png'
# print(a.split('/')[-1:][0])

# game_count = 10
# game_count_ok = 2
# msg = f"game: {game_count_ok}/{game_count}"
# zz_dingtalk.send_markdown(f"{msg} \n\n 运行时长：{round(time_duration.seconds / 60, 1)}分钟", msg)

# token = zz_code.env("CHEANGTOU_TOKEN")
# token_arr = zz_str.split2(token)
#
# handle = api_chengtou.Handle(token_arr[0][0], token_arr[0][1], 'o3y1-66d_13d7gz85lB6-DS7kfj0')
# r = handle.api_browse('2525284209070003236')
# print(r.to_json())
#
# hua = 2
# for i in range(3, 29, 1):
#     hua = hua * 2
#     print(f'{i}天 花：{hua}')

def config_to_return() -> list:
    """
    配置 转 r
    :return:
    """
    fund_config_str = zz_code.get_file_content("./fund.json")
    fund_config_arr = json.loads(fund_config_str)
    arr_config = []
    for item in fund_config_arr:
        json_str = json.dumps(item, ensure_ascii=False)
        arr_config.append(zz_return.parse(json_str))
    return arr_config


list = config_to_return()
for e in list:
    print(e.to_json())
# print(r.get_data("fund")[0])
